#!/usr/bin/python
# fileencoding: utf-8
"""
json转lua表结构
"""
import sys
import json
import re

def quote_str(text):
	return "\"%s\""%re.sub("\"", "\\\"", text)

def dump_obj(value, buff):
	if type(value) in (list, dict, ):
		buff.append("{")
		if isinstance(value, list):
			for element in value:
				dump_obj(element, buff)
				buff.append(",")
		else:
			for key in value:
				if type(key) in (int, long, float, ):
					buff.append("[%s] = "%(key))
				elif type(key) in (str, unicode, ):
					buff.append("[%s] ="%(quote_str(key)))
				else:
					raise ValueError("fuck you! %s"%type(key))
				dump_obj(value[key], buff)
				buff.append(",")
		buff.append("}")
	elif type(value) in (int, long, float, ):
		buff.append("%s"%(value))
	elif type(value) in (str, unicode ):
		buff.append(quote_str(value))
	else:
		raise ValueError("fuck you! %s"%type(value))

def json_to_lua(text):
	buff = []
	dump_obj(json.loads(text), buff)
	return "".join(buff)

print json_to_lua(sys.argv[1])
